<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>用户管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <!--引入本地的css样式-->
  <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../static/css/admin.css" media="all">

</head>
<body>

  <div class="layui-fluid">   
    <div class="layui-card">
      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">用户姓名</label>
            <div class="layui-input-block">
              <input type="text" name="employee_name" placeholder="输入用户名称" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-search">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
          </div>
        </div>
      </div>
      
      <div class="layui-card-body">
        <div style="padding-bottom: 10px;">
          <button class="layui-btn layuiadmin-btn-admin" data-type="batchdel">删除</button>
          <button class="layui-btn layuiadmin-btn-admin" id="add_employee" data-type="add_employee">添加</button>
        </div>
        
        <table id="LAY-user-back-manage" lay-filter="LAY-user-back-manage"></table>

        <script type="text/html" id="buttonTpl">
          {{#  if(d.check == true){ }}
            <button class="layui-btn layui-btn-xs">已审核</button>
          {{#  } else { }}
            <button class="layui-btn layui-btn-primary layui-btn-xs">未审核</button>
          {{#  } }}
        </script>
        <script type="text/html" id="table-useradmin-admin">
          <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
          {{#  if(d.role == '超级管理员'){ }}
            <a class="layui-btn layui-btn-disabled layui-btn-xs"><i class="layui-icon layui-icon-delete"></i>删除</a>
          {{#  } else { }}
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
          {{#  } }}
        </script>
      </div>
    </div>
  </div>

<script src="../../static/js/jquery-3.6.0.min.js"></script>
<!--引入本地layui.js-->
<script src="../../static/layui/layui.js"></script>
<!--js-->
<script type="text/javascript">
    layui.config({
        base: '../../static/layui/layuiadmin/' //静态资源所在路径js
    }).extend({
        index: 'lib/index' //主入口模块
    }).use('index');
</script>

  <script type="text/javascript">
      layui.use('table', function(){
          var table = layui.table;

          table.render({
              elem: '#LAY-user-back-manage'
              ,url:'后端接口'
              ,title: '用户数据表'
              ,cols: [[
                  {type: 'checkbox', fixed: 'left'}
                  ,{field:'id', title:'ID', fixed: 'left', unresize: true, sort: true}
                  ,{field:'username', title:'用户名称',}
                  ,{field:'password', title:'密码',sort: true}
                  ,{field:'sex', title:'性别'}
                  ,{field:'tel', title:'电话号码'}
                  ,{field:'email', title:'联系方式',sort: true}
                  ,{field:'user_picture', title:'用户头像'}
                  ,{field:'status', title:'状态',sort: true}
                  ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
              ]]
              ,page: true
          });

          //监听添加、和删除事件
          $("#add_employee").click(function () {
              layer.open({
                  type: 2
                  ,title: '添加员工'
                  ,content: 'add.html'
                  ,area: ['50%', '60%']
                  ,btn: ['确定', '取消']
                  ,yes: function(index, layero){
                      var iframeWindow = window['layui-layer-iframe'+ index]
                          ,submitID = 'LAY-user-back-submit'
                          ,submit = layero.find('iframe').contents().find('#'+ submitID);

                      //监听提交
                      iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                          var field = data.field; //获取提交的字段

                          //提交 Ajax 成功后，静态更新表格中的数据
                          //$.ajax({});
                          table.reload('LAY-user-front-submit'); //数据刷新
                          layer.close(index); //关闭弹层
                      });

                      submit.trigger('click');
                  }
              });
          })



      });
  </script>

</body>
</html>

